package com.toolmanrln.common.api;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @author ToolMan.RLN
 * @since 2020-05-15 17:55
 */
@Data
@ApiModel(value = "分页搜索条件", description = "分页搜索条件")
public class PageQuery {

    @ApiModelProperty(value = "页码", name = "page", required = true, dataType = "Integer", example = "1")
    @Min(value = 1, message = "page下限为1")
    @NotNull(message = "页码不能为空")
    private Integer page;

    @ApiModelProperty(value = "每页条目数", name = "pageSize", required = true, dataType = "Integer", example = "20")
    @Max(value = 1000, message = "pageSize上限为1000")
    @Min(value = 1, message = "pageSize下限为1")
    @NotNull(message = "每页条目数不能为空")
    private Integer pageSize;

    @ApiModelProperty(value = "排序方式(asc 或者 desc)，与orderByField成对必填", name = "sort", required = false, dataType = "String", example = "desc")
    private String sort;

    @ApiModelProperty(value = "排序的字段名称，与sort成对必填", name = "orderByField", required = false, dataType = "String", example = "id")
    private String orderByField;
}
